<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="common/include :: header('新增员工')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-salary-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">员工姓名：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="name" id="name" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">基础工资：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="basicSalary" id="basicSalary" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">绩效工资：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="meritSalary" id="meritSalary" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">扣款：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="deductMoney" id="deductMoney" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">发放方式：</label>
            <div class="col-sm-8">
                <select name="paySource" class="form-control m-b" th:with="type=${@dict.getType('pay_source')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">发放时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="date" class="form-control" placeholder="yyyy-MM-dd HH:mm" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">备注：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="info" id="info">
            </div>
        </div>
    </form>
</div>
<th:block th:include="common/include :: footer"/>
<th:block th:include="common/include :: datetimepicker"/>
<script type="text/javascript">
    var prefix = ctx + "/business/salary";
    $("#form-salary-add").validate({
        onkeyup: false,
        rules: {
            name: {
                required: true,
                rangelength: [2, 10]

            },
            basicSalary: {
                required: true,
                digits: true
            },
            meritSalary: {
                required: true,
                digits: true

            },
            deductMoney: {
                required: true,
                digits: true,
                range: [1, 130]
            },
            realSalary: {
                required: true,
                digits: true

            },
            paySource: {
                required: true,
                digits: true
            }

        },
        messages: {
            name: {
                required: "姓名必填",
                rangelength: "姓名为2~10个汉字"
            },
            basicSalary: {
                required: "基础工资必填",
                digits: "工资必须为数字",
            },
            meritSalary: {
                required: "绩效工资必填",
                digits: "工资必须为数字",
            },
            deductMoney: {
                required: "扣款",
                digits: "扣款必须为数字",
            },
            realSalary: {
                required: "实际工资必填",
                digits: "实际工资必须为数字",
            }

        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-salary-add').serialize());
        }
    }

    $("input[name='date']").datetimepicker({
        format: "yyyy-mm-dd hh:ii",
        autoclose: true
    });
</script>
</body>
</html>
